<?php
namespace app\common\model;
use think\Model;

class VisitorModel extends Model{
    protected  $name = 'visitor';
    protected  $pk   = 'visitor_id';
    
    public static function onBeforeInsert($model)
    {
        $model->set("create_ip", request()->ip());
    }
    public function staff(){
        return $this->hasOne(StaffModel::class,'staff_id','staff_id')->bind(['name','mobile','position','code']);
    }
    
    public function firm(){
        return $this->hasOne(FirmDetailModel::class,'firm_id','firm_id')->bind(['company_name','logo']);
    }
    
    public function staffDetail(){
        return $this->hasOne(StaffDetailModel::class,'staff_id','staff_id')->bind(['face','weixin']);
    }
}